<?php 

require_once("../models/config.php");
require_once("../ui.php");
require_once("../stats/db.php");
include_once("bar.graph.php");

if (!isUserViewAuthorized()) {
	echo "Unauthorized access";
	die();
}

global $loggedInUser;
global $db;

$sql = "SELECT `Id` AS Id, `Name` AS Name FROM `debugging_Tool_Categories` ORDER BY `Name`";

$result = $db->sql_query($sql);
if (!$result) {
	$error = $db->sql_error();
	return;
}

$categories = array();
$names = array();
$categoryUsages = array();

$rows = $db->sql_fetchall();
foreach($rows as $i => $row) {
	$categories[] = $row['Id'];
	$names[] = $row['Name'];
	$categoryUsages[] = getToolUsagesForCategory($row['Id']);
}

drawMyBarGraph($categoryUsages, "Usages", $names, "Tool category", "How many times were debugging tools used",
	array());

?>